<!DOCTYPE HTML>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">

<f:view>
    <f:metadata>
        <!-- Start a new process instance. Process Definition Key is read internally from
             request parameters and cached in the CDI conversation scope.
             NOTE: Syntax is different when working on user task forms, see file "approveLoanRequest.xhtml". -->
        <f:event type="preRenderView" listener="#{camundaTaskForm.startProcessInstanceByKeyForm()}" />
    </f:metadata>
    <h:head>
        <title>Submit Loan Request</title>
    </h:head>
    <h:body>
        <h2>Start Process Instance</h2>
        <h1>External Forms Quickstart</h1>
        <hr />
        <h1>Submit Loan Request</h1>
        <h:form id="submitForm">
            <h:panelGrid columns="2">
                <p>
                    <label for="firstname">First Name</label>
                    <!-- create process variables using the processVariables map. -->
                    <h:inputText id="firstname" value="#{processVariables['firstname']}" required="true" />
                </p>
                <p>
                    <label for="lastname">Last Name</label>
                    <h:inputText id="lastname" value="#{processVariables['lastname']}" required="true" />
                </p>
                <p>
                    <label for="netIncome">Net Income</label>
                    <h:inputText id="netIncome" value="#{processVariables['netIncome']}" converter="javax.faces.Integer" required="true" />
                </p>
                <p>
                    <label for="amount">Loan Amount</label>
                    <!-- use type converters to convert process variables to the correct type. -->
                    <h:inputText id="amount" value="#{processVariables['amount']}" converter="javax.faces.Integer" required="true" />
                </p>
            </h:panelGrid>

            <!-- The button starts a new process instance. This ends the conversation and redirects us to the tasklist.
                 NOTE: Syntax is different when working on user task forms, see file "approveLoanRequest.xhtml". -->
            <h:commandButton id="submit_button" value="Submit Request" action="#{camundaTaskForm.completeProcessInstanceForm()}" />

            <h:messages style="color:red;margin:8px;" />
        </h:form>
    </h:body>
</f:view>
</html>